<html>
<head><meta charset="utf-8"><title>post 0.2 perf work: small_vec · t-cargo/PubGrub · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/index.html">t-cargo/PubGrub</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html">post 0.2 perf work: small_vec</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217034117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217034117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217034117">(Nov 17 2020 at 17:22)</a>:</h4>
<p>So I have had this idea for a while, and gave it a try when I read  <a href="https://nnethercote.github.io/perf-book/heap-allocations.html#short-vecs">https://nnethercote.github.io/perf-book/heap-allocations.html#short-vecs</a><br>
Most <code>Range</code>s have at most 2 <code>Interval</code>s, so try using a small_vec for storing it. <a href="https://github.com/pubgrub-rs/pubgrub/compare/dev...small_vec">Here is the diff</a>, and I am seeing unreasonably good perf improvements. Like 50%<br>
If one of you has a chance, can you check if you are getting similar improvements?</p>



<a name="217034723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217034723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217034723">(Nov 17 2020 at 17:27)</a>:</h4>
<p>Nice! I was wondering about it too but I kind of remember reading somewhere a post about <code>small_vec</code> not being safe (or maybe it was for an alternative of small_vec, don't remember</p>



<a name="217034994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217034994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217034994">(Nov 17 2020 at 17:29)</a>:</h4>
<p><a href="https://www.reddit.com/r/rust/comments/fshuhk/introducing_tinyvec_100_safe_alternative_to/">https://www.reddit.com/r/rust/comments/fshuhk/introducing_tinyvec_100_safe_alternative_to/</a></p>



<a name="217035502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217035502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217035502">(Nov 17 2020 at 17:32)</a>:</h4>
<p>Similarly, most incompatibilities have two entries, do you know of a <code>tiny_map</code>? :)</p>



<a name="217036082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217036082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217036082">(Nov 17 2020 at 17:37)</a>:</h4>
<p>I have a similar impression about small_vec having safety issues, and I'd need to verify that since I just vaguely remember as well(</p>



<a name="217036249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217036249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217036249">(Nov 17 2020 at 17:38)</a>:</h4>
<p>That was going to be my next comment! Yes small_vec has a history of using unsafe wrong. (<a href="https://github.com/RustSec/advisory-db/tree/master/crates/smallvec">https://github.com/RustSec/advisory-db/tree/master/crates/smallvec</a>). It is not know to be broken at the moment, but ....</p>



<a name="217036381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217036381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217036381">(Nov 17 2020 at 17:39)</a>:</h4>
<p>I also remember mentions of other crates in the space, maybe there are alternatives that would also be good. <br>
However, if they fixed the issues why not give them a chance. Everyone makes mistakes.</p>



<a name="217036502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217036502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217036502">(Nov 17 2020 at 17:40)</a>:</h4>
<p>If one of you confirms the perf wins, then I will start looking into alternative implementations.</p>



<a name="217036615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217036615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217036615">(Nov 17 2020 at 17:41)</a>:</h4>
<p>I don't know of a <code>tiny_map</code>, but for the limited functionality we need it is not hard to roll our own.</p>



<a name="217036891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217036891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217036891">(Nov 17 2020 at 17:43)</a>:</h4>
<p>In fact we don't need much from the vec in <code>Range</code>. One alternative is to roll our own. Small_vec just has such a small diff that it seemed a good place to start measuring the perf.</p>



<a name="217037085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037085">(Nov 17 2020 at 17:45)</a>:</h4>
<p>cc: <a href="#narrow/stream/146229-wg-secure-code/topic/tinyvec.20without.20default">https://rust-lang.zulipchat.com/#narrow/stream/146229-wg-secure-code/topic/tinyvec.20without.20default</a></p>



<a name="217037125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037125">(Nov 17 2020 at 17:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120179">Eh2406</span> <a href="#narrow/stream/260232-t-cargo.2FPubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec/near/217036502">said</a>:</p>
<blockquote>
<p>If one of you confirms the perf wins, then I will start looking into alternative implementations.</p>
</blockquote>
<p>I'll run the benchmark shortly. I'm not saying we should disregard <code>small_vec</code>because of past issues, but I very much like the idea of exploring available options.</p>



<a name="217037340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037340">(Nov 17 2020 at 17:47)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[derive(Debug, Clone)]</span><span class="w"></span>
<span class="k">enum</span> <span class="nc">SmallMap</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span><span class="w"> </span><span class="n">V</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">One</span><span class="p">([(</span><span class="n">K</span><span class="p">,</span><span class="w"> </span><span class="n">V</span><span class="p">);</span><span class="w"> </span><span class="mi">1</span><span class="p">]),</span><span class="w"></span>
<span class="w">    </span><span class="n">Two</span><span class="p">([(</span><span class="n">K</span><span class="p">,</span><span class="w"> </span><span class="n">V</span><span class="p">);</span><span class="w"> </span><span class="mi">2</span><span class="p">]),</span><span class="w"></span>
<span class="w">    </span><span class="n">Flexible</span><span class="p">(</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span><span class="w"> </span><span class="n">V</span><span class="o">&gt;</span><span class="p">),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Is one way to roll our own <code>tiny_map</code>, a <code>tiny_vec</code> can work similarly.</p>



<a name="217037537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037537">(Nov 17 2020 at 17:48)</a>:</h4>
<p>the code is not compiling for me in your small_vec branch</p>



<a name="217037611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037611">(Nov 17 2020 at 17:49)</a>:</h4>
<p>ba humbug. let me see...</p>



<a name="217037737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037737">(Nov 17 2020 at 17:50)</a>:</h4>
<p>I was using <code>cargo bench --features=serde</code> and got compilations errors about range not be serializable because smallvec</p>



<a name="217037802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037802">(Nov 17 2020 at 17:50)</a>:</h4>
<p>Right, that is the other thing to fix. <code>cargo bench --features=serde-1</code></p>



<a name="217037876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037876">(Nov 17 2020 at 17:51)</a>:</h4>
<p>where <code>serde-1</code> therns on serde for pubgrub and the serde feature of smallvec.</p>



<a name="217037947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037947">(Nov 17 2020 at 17:52)</a>:</h4>
<p>I just run with '--all-features' and it worked.</p>



<a name="217037978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217037978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217037978">(Nov 17 2020 at 17:52)</a>:</h4>
<p>change: [-30.169% -28.831% -27.451%] (p = 0.00 &lt; 0.05)</p>



<a name="217038019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217038019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217038019">(Nov 17 2020 at 17:52)</a>:</h4>
<p>So not 50% but still big.</p>



<a name="217038074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217038074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217038074">(Nov 17 2020 at 17:53)</a>:</h4>
<p>There are still a few "Vec::new()" in the code in <code>small_vec</code> branch</p>



<a name="217038095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217038095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217038095">(Nov 17 2020 at 17:53)</a>:</h4>
<p>Let me see if replacing them makes a difference</p>



<a name="217038112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217038112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217038112">(Nov 17 2020 at 17:53)</a>:</h4>
<p>got 13% improvement on the elm dataset and 22% improvement for the synthetic one</p>



<a name="217038511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217038511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217038511">(Nov 17 2020 at 17:56)</a>:</h4>
<blockquote>
<p>There are still a few "Vec::new()" in the code in small_vec branch</p>
</blockquote>
<p>Actually maybe that's on purpose, not every Vec in our library does not grow</p>



<a name="217038559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217038559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217038559">(Nov 17 2020 at 17:57)</a>:</h4>
<p>So worth pursuing, but not as big as I was seeing. I wonder why the difference, but I will keep playing with this idea. Thank you all.</p>



<a name="217040451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217040451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217040451">(Nov 17 2020 at 18:10)</a>:</h4>
<p>I see mentions of <code>array_vec</code> that we also might want to try</p>



<a name="217040582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217040582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217040582">(Nov 17 2020 at 18:10)</a>:</h4>
<p>that works when we know there can't be more than N elements.</p>



<a name="217065785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217065785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217065785">(Nov 17 2020 at 21:30)</a>:</h4>
<p>I am done with meetings, so I can run benchmarks on my version of small vec:<br>
<a href="https://github.com/pubgrub-rs/pubgrub/commit/ba5a873d8d188305717127484f86710aabc7240e#diff-fbd4e90bd1c07576edba7f752cccda844f7209ef6f79c25b665bbeceb97c629c">https://github.com/pubgrub-rs/pubgrub/commit/ba5a873d8d188305717127484f86710aabc7240e#diff-fbd4e90bd1c07576edba7f752cccda844f7209ef6f79c25b665bbeceb97c629c</a><br>
for me it works just as well!</p>
<div class="codehilite" data-code-language="cmd"><pre><span></span><code>large_cases/elm-packages_str_SemanticVersion.ron
                        time:   [793.53 ms 817.06 ms 840.83 ms]
                        change: [-51.001% -49.380% -47.701%] (p = 0.00 &lt; 0.05)
                        Performance has improved.
large_cases/large_case_u16_NumberVersion.ron
                        time:   [35.874 ms 36.137 ms 36.408 ms]
                        change: [-56.441% -55.656% -54.887%] (p = 0.00 &lt; 0.05)
                        Performance has improved.
</code></pre></div>



<a name="217068328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217068328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217068328">(Nov 17 2020 at 21:53)</a>:</h4>
<p>This is awesome if we get that kind of improvements! One remark on the code, it would be better to have <code>Range</code> be a newtype over the custom small vec (like now with Vec inside) instead of have its internals public</p>



<a name="217069576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217069576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217069576">(Nov 17 2020 at 22:03)</a>:</h4>
<p>I assume if I am getting the same 50% improvements then you will see the same 13-20% improvements. I don't know why it is so high for me, windows or <code>target-cpu=native</code> or don't know.<br>
Good point I forgot it was publick.</p>



<a name="217069897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217069897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217069897">(Nov 17 2020 at 22:06)</a>:</h4>
<p>Maybe I'll get better performances with this than with small vec :) will test probably in the weekend. After v0.2 is published I'll take a few days break at least ^^ and get back to my paid work ahah</p>



<a name="217069960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217069960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217069960">(Nov 17 2020 at 22:07)</a>:</h4>
<p>I took a week off, it was sweet but it ends now :(</p>



<a name="217075548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217075548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217075548">(Nov 17 2020 at 23:03)</a>:</h4>
<p>good call on keeping it private it looks much better.</p>



<a name="217075555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217075555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217075555">(Nov 17 2020 at 23:03)</a>:</h4>
<p><a href="https://github.com/pubgrub-rs/pubgrub/commit/c63cee0485ac5336f2eea2fae74ccccc8dbe5140">https://github.com/pubgrub-rs/pubgrub/commit/c63cee0485ac5336f2eea2fae74ccccc8dbe5140</a></p>



<a name="217122337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217122337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217122337">(Nov 18 2020 at 11:24)</a>:</h4>
<p>Just tested the small_vec branch this morning and getting 24% improvement on elm packages and 44% improvement on large case.</p>



<a name="217137612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217137612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217137612">(Nov 18 2020 at 14:02)</a>:</h4>
<p>I'll take it!</p>



<a name="217139415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217139415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217139415">(Nov 18 2020 at 14:17)</a>:</h4>
<p>I will put a PR up after we get 0.2 up!</p>



<a name="217142849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217142849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217142849">(Nov 18 2020 at 14:42)</a>:</h4>
<p>Might as well add it now, it's internal API why not</p>



<a name="217142907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217142907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217142907">(Nov 18 2020 at 14:43)</a>:</h4>
<p>Do you like our own definition more than external crate?</p>



<a name="217144473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217144473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217144473">(Nov 18 2020 at 14:54)</a>:</h4>
<p>I haven't thought of all the implications of this yet. And there are places where this is half backed, like for example there is a fallback to hashmap for prior cause computation etc. No need to rush this into v02. It's also good to know there will be nice things coming for v03 ^^</p>



<a name="217144850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217144850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217144850">(Nov 18 2020 at 14:56)</a>:</h4>
<p>I thought this PR is only about Vecs and doesn't attempt to provide a Map.<br>
But yeah, no rush merging it. What I meant to say there is no reason to not put the PR up for review when it's ready.</p>



<a name="217144959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217144959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217144959">(Nov 18 2020 at 14:57)</a>:</h4>
<p>I added a commit for a small_map.</p>



<a name="217161670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217161670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217161670">(Nov 18 2020 at 16:41)</a>:</h4>
<blockquote>
<p>And there are places where this is half backed, like for example there is a fallback to hashmap for prior cause computation etc. </p>
</blockquote>
<p>Yes that is half baked, but most incompatibilities come from dependencies so I don't think it <em>needs</em> to be fixed. And it is a perf win as is, so it is worth it even if we don't fix it. But that can get discussed in the PR when it is up.</p>



<a name="217483355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217483355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217483355">(Nov 21 2020 at 04:05)</a>:</h4>
<p>just went ahead and fixed it. and the PR is up.</p>



<a name="217505907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217505907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217505907">(Nov 21 2020 at 15:25)</a>:</h4>
<p>Btw, why didn't we just pull a dep for this in the end?</p>



<a name="217510117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217510117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217510117">(Nov 21 2020 at 17:17)</a>:</h4>
<p>What do you think of using a dep for a vector implementation but implementing our own map since you said it doesn't exist?</p>



<a name="217510197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217510197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217510197">(Nov 21 2020 at 17:19)</a>:</h4>
<p>Although I see some crates we can try out as well, e.g. <a href="https://lib.rs/crates/smallmap">https://lib.rs/crates/smallmap</a></p>



<a name="217517122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217517122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217517122">(Nov 21 2020 at 20:18)</a>:</h4>
<p>Lost some time to a headache today. I will follow up with this when I am feeling better. All the feedback is really good, I am just not up to dealing right now.</p>



<a name="217521749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217521749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217521749">(Nov 21 2020 at 22:13)</a>:</h4>
<p>Had a few mins and was able to look into the smallmap crate you linked, and there is a lot I don't get about it. But one think I'm pretty sure of is that it does allocate <a href="https://github.com/notflan/smallmap/blob/master/src/lib.rs#L184">https://github.com/notflan/smallmap/blob/master/src/lib.rs#L184</a>. I think we are getting the speed up by not allocating when making incompatibilities and not having the cache miss when reading them. So whatever use case that crate is intended for I don't think it is ours.</p>



<a name="217522573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/post%200.2%20perf%20work%3A%20small_vec/near/217522573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/post.200.2E2.20perf.20work.3A.20small_vec.html#217522573">(Nov 21 2020 at 22:36)</a>:</h4>
<p>Yeah I was just a random link; I haven't analyzed applicability of various options, just saw that there were a few.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>